home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Actual 85 Febrero 2004.iso / Experto / Apache / apache_2.0.48-win32-x86-no_ssl.msi / Data.Cab / F251759_apr_optional_hooks.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-31  |  5.8 KB  |  156 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  */
  54. /**
  55.  * @file apr_optional_hooks.h
  56.  * @brief Apache optional hook functions
  57.  */
  58.  
  59.  
  60. #ifndef APR_OPTIONAL_HOOK_H
  61. #define APR_OPTIONAL_HOOK_H
  62.  
  63. #include "apr_tables.h"
  64.  
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68. /** 
  69.  * @defgroup APR_Util_OPT_HOOK Optional Hook Functions
  70.  * @ingroup APR_Util_Hook
  71.  * @{
  72.  */
  73. /**
  74.  * Function to implemnt the APR_OPTIONAL_HOOK Macro
  75.  * @internal
  76.  * @see APR_OPTIONAL_HOOK
  77.  *
  78.  * @param name The name of the hook
  79.  * @param pfn A pointer to a function that will be called
  80.  * @param aszPre a NULL-terminated array of strings that name modules whose hooks should precede this one
  81.  * @param aszSucc a NULL-terminated array of strings that name modules whose hooks should succeed this one
  82.  * @param nOrder an integer determining order before honouring aszPre and aszSucc (for example HOOK_MIDDLE)
  83.  */
  84.  
  85.  
  86. APU_DECLARE(void) apr_optional_hook_add(const char *szName,void (*pfn)(void),
  87.                     const char * const *aszPre,
  88.                     const char * const *aszSucc,
  89.                     int nOrder);
  90.  
  91. /**
  92.  * Hook to an optional hook.
  93.  *
  94.  * @param ns The namespace prefix of the hook functions
  95.  * @param name The name of the hook
  96.  * @param pfn A pointer to a function that will be called
  97.  * @param aszPre a NULL-terminated array of strings that name modules whose hooks should precede this one
  98.  * @param aszSucc a NULL-terminated array of strings that name modules whose hooks should succeed this one
  99.  * @param nOrder an integer determining order before honouring aszPre and aszSucc (for example HOOK_MIDDLE)
  100.  */
  101.  
  102. #define APR_OPTIONAL_HOOK(ns,name,pfn,aszPre,aszSucc,nOrder) \
  103.     ((void (APR_THREAD_FUNC *)(const char *,ns##_HOOK_##name##_t *,const char * const *, \
  104.            const char * const *,int))&apr_optional_hook_add)(#name,pfn,aszPre, \
  105.                                aszSucc, nOrder)
  106.  
  107. /**
  108.  * @internal
  109.  * @param szName - the name of the function
  110.  * @return the hook structure for a given hook
  111.  */
  112. APU_DECLARE(apr_array_header_t *) apr_optional_hook_get(const char *szName);
  113.  
  114. /**
  115.  * Implement an optional hook that runs until one of the functions
  116.  * returns something other than OK or DECLINE.
  117.  *
  118.  * @param ns The namespace prefix of the hook functions
  119.  * @param link The linkage declaration prefix of the hook
  120.  * @param ret The type of the return value of the hook
  121.  * @param ret The type of the return value of the hook
  122.  * @param name The name of the hook
  123.  * @param args_decl The declaration of the arguments for the hook
  124.  * @param args_use The names for the arguments for the hook
  125.  * @param ok Success value
  126.  * @param decline Decline value
  127.  */
  128. #define APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ns,link,ret,name,args_decl,args_use,ok,decline) \
  129. link##_DECLARE(ret) ns##_run_##name args_decl \
  130.     { \
  131.     ns##_LINK_##name##_t *pHook; \
  132.     int n; \
  133.     ret rv; \
  134.     apr_array_header_t *pHookArray=apr_optional_hook_get(#name); \
  135. \
  136.     if(!pHookArray) \
  137.     return ok; \
  138. \
  139.     pHook=(ns##_LINK_##name##_t *)pHookArray->elts; \
  140.     for(n=0 ; n < pHookArray->nelts ; ++n) \
  141.     { \
  142.     rv=(pHook[n].pFunc)args_use; \
  143. \
  144.     if(rv != ok && rv != decline) \
  145.         return rv; \
  146.     } \
  147.     return ok; \
  148.     }
  149.  
  150. /** @} */
  151. #ifdef __cplusplus
  152. }
  153. #endif
  154.  
  155. #endif /* APR_OPTIONAL_HOOK_H */
  156.